package br.com.taskManager.hibernate;

import org.apache.log4j.Logger;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {

	private static final SessionFactory	sessionFactory	= buildSessionFactory();
	
	private static final Logger logger = Logger.getLogger(HibernateUtil.class);
  
	private static SessionFactory buildSessionFactory() {
    try {
    	return new Configuration().configure().buildSessionFactory();
    } catch (Throwable e) {
    	logger.fatal("Criação inicial do objeto SessionFactory falhou. Erro: ", e);
		throw new ExceptionInInitializerError(e);
    }
  }
  
	public static SessionFactory getSessionFactory() {
		return sessionFactory;
	}	
}